﻿using HCQ2_IDAL;
using HCQ2_Model.VRDevice.ParamModel;
using HCQ2_Model.VRDevice.ResultModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2_DAL_MSSQL
{
    public partial class T_DocEmpowerDAL: IT_DocEmpowerDAL
    {
        /// <summary>
        ///  获取授权列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Task<List<AuthorUserResult>> GetAuthorUser(AuthorUser model)
        {
            sb?.Clear();
            sb.Append($@"SELECT em.*,users.user_name,users.login_name,users.user_guid as userid FROM (SELECT user_id,user_name,login_name,user_guid FROM dbo.T_User)users INNER JOIN (SELECT user_id,num_code,CONVERT(varchar(100),start_date,120) AS start_date,CONVERT(varchar(100),end_date,120) AS end_date,machine_code,machine_name,doc_note FROM dbo.T_DocEmpower WHERE num_code='{model.numCode}')em ON em.user_id = users.user_id; ");
            DataTable dt = HCQ2_Common.SQL.SqlHelper.ExecuteDataTable(sb.ToString());
            return Task.Run(() => { return HCQ2_Common.Data.DataTableHelper.DataTableToIList<AuthorUserResult>(dt); });
        }
    }
}